#include <iostream>
#include <thread>
#include <mutex>

std::mutex mu;

void shared_print(std::string msg, int id)
{
    mu.lock();
    std::cout << msg << id << std::endl;
    mu.unlock();
}

void function_1()
{
    for(int i = 0; i > -100; --i)
    {
        shared_print("from fn1:",i);
    }
}

int t1_main()
{
    std::thread t1(function_1);

    for(int i=0; i < 100; ++i)
        shared_print("from main:",i);

    t1.join();

    return 0;
}